package net.cyan.crud.arachne;

import net.cyan.arachne.*;
import net.cyan.commons.util.*;
import net.cyan.crud.*;

/**
 * @author camel
 * @date 2009-7-13
 */
public class ArachneCrudContext implements HttpCrudContext
{
    public ArachneCrudContext()
    {
    }

    public Crud getCrud()
    {
        return (Crud) RequestContext.getContext().getForm();
    }

    public String getAction()
    {
        return RequestContext.getContext().getMethod();
    }

    public Object eval(String expression, Object obj) throws Exception
    {
        ForwardContext forwardContext = RequestContext.getContext().getForwardContext();
        return forwardContext == null ? BeanUtils.eval(expression, obj, null) : forwardContext.eval(expression, obj);
    }

    public String getUrl(Class<? extends Crud> crudType, String method, String queryString, Object... parameters)
            throws Exception
    {
        return PageClass.getClassInfo(crudType).getUrl(method, queryString, parameters);
    }

    public BeanProvider getBeanProvider()
    {
        return PageConfig.getBeanProvider();
    }
}
